package com.xm.service.background;

import com.xm.dao.background.AdministratorInformationDao;
import com.xm.entity.AdministratorInformation;
import com.xm.entity.Page;
import com.xm.exception.SqlErrorException;

import java.util.List;

/**
 * AdministratorInformation的Service层
 *
 * @author 康文程
 * @date 2023-12-15 下午 03:29
 */
public class AdministratorInformationService {
    private final AdministratorInformationDao dao = new AdministratorInformationDao();

    /**
     * 查询全部AdministratorInformation
     *
     * @return List集合
     */
    public List<AdministratorInformation> getAll() {
        return dao.findAll();
    }


    /**
     * 根据 administrator_id 查询账号信息
     *
     * @return AdministratorInformation对象
     */
    public AdministratorInformation getAdministratorById(String id) {
        return dao.queryByAdministratorId(id);
    }

    /**
     * 分页查询
     *
     * @param pageNumber 分页页数
     * @param pageSize   每页数量
     * @return page<对象>
     */
    public Page<AdministratorInformation> pagination(int pageNumber, int pageSize, String employeeMc, String departmentId, String administratorState, String dateEntry) {
        return dao.pagination(pageNumber, pageSize, employeeMc, departmentId, administratorState, dateEntry);
    }

    /**
     * 添加或修改员工
     * 如果传了getInformationId则修改没有则新增
     *
     * @param administratorInformation 员工实体类
     * @throws SqlErrorException SQL执行异常
     */
    public boolean addAdministratorInformation(AdministratorInformation administratorInformation) throws SqlErrorException {
        return dao.addAdministratorInformation(administratorInformation);
    }

    /**
     * 查询员工名称和职称
     *
     */
    public List<AdministratorInformation> getFindName(String name) {
        return dao.findName(name);
    }
}
